package com.sc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sc.domain.Repair;
import com.sc.dto.RepairDateDTO;
import com.sc.dto.RepairPageDTO;
import com.sc.mapper.RepairMapper;
import com.sc.result.PageResult;
import com.sc.service.RepairService;
import com.sc.vo.RepairVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> implements RepairService {


    /**
     * 分页查询维修记录
     *
     * @param repairPageDTO 传入查询条件
     * @return 查询结果
     */
    @Override
    public PageResult<RepairVO> pageQuery(RepairPageDTO repairPageDTO) {
        //开始分页
        PageHelper.startPage(repairPageDTO.getPage(),repairPageDTO.getPageSize());
        Page<RepairVO> page = baseMapper.pageQuery(repairPageDTO);
        return new PageResult<>(page.getTotal(),page.getResult());
    }

    @Override
    // 动态查询报修记录
    public List<RepairVO> queryRepairData(RepairDateDTO repairDateDTO) {

        return baseMapper.queryRepairData(repairDateDTO);
    }
}
